koreaHeatMap = function(move, cost, model, data=spscale, fileID) {
  
  # Define the bounds
  moveVar = data[[move]]
  costVar = data[[cost]]
  
  seqRI = seq(min(moveVar), max(moveVar), length=10)
  seqRC = seq(min(costVar), max(costVar), length=10)
  
  # Make the matrix
  predprob = matrix(NA, 10 , 10)
  
  for (i in 1:length(seqRI)) {
    for (j in 1:length(seqRC)) {
      testobs = data.frame(ri30 = seqRI[i], rollBothLoss30l=seqRC[j],
                           ri60 = seqRI[i], rollBothLoss60l=seqRC[j],
                           ri90 = seqRI[i], rollBothLoss90l=seqRC[j],
                           winter=median(data[['winter']]), logCombatSorties=mean(data[['logCombatSorties']], na.rm=T),
                           logRepLength=mean(data[['logRepLength']]), election=median(data[['election']]),
                           eisenhower=median(data[['eisenhower']]), stalin=median(data[['stalin']]),
                           speaker="UNC", meetTypeMain="Plenary", 
                           date=median(sp$date))
      
      predprob[i, j] = predict(model, newdata=testobs, type="response")
    }
  }
  predprob2 = reshape2::melt(predprob)
  predprob2$movement = rep(seqRI, 10)
  predprob2$casualties = rep(seqRC, each=10)
  
  # Get the corner predictions
  pred_lowmove_lowcost = predprob2$value[which(predprob2$Var1==1 & predprob2$Var2==1)]
  pred_highmove_lowcost = predprob2$value[which(predprob2$Var1==10 & predprob2$Var2==1)]
  pred_lowmove_highcost = predprob2$value[which(predprob2$Var1==1 & predprob2$Var2==10)]
  pred_highmove_highcost = predprob2$value[which(predprob2$Var1==10 & predprob2$Var2==10)]
  
  # Generate the heatmap 
  heatmap = ggplot(data = predprob2, aes(x=movement, y=casualties, fill=value)) + 
    geom_tile() + theme_bw() + 
    theme(legend.position="bottom", 
          legend.direction = "horizontal") +
    scale_x_continuous("Recent imbalance", 
                       breaks=c(min(predprob2$movement), median(predprob2$movement), max(predprob2$movement)),
                       labels=round(c(min(sp[[move]]), median(sp[[move]]), max(sp[[move]])), 3)) +
    scale_y_continuous("Recent casualties", 
                       breaks=c(min(predprob2$casualties), median(predprob2$casualties), max(predprob2$casualties)),
                       labels=round(exp(c(min(sp[[cost]]), median(sp[[cost]]), max(sp[[cost]]))), 0)) +
    scale_fill_gradient("Sincerity", low="gray10", high="gray80")
  
  print(heatmap)
  
  message("Low movement, low costs: ", round(pred_lowmove_lowcost, 3))
  message("High movement, low costs: ", round(pred_highmove_lowcost, 3))
  message("Low movement, high costs: ", round(pred_lowmove_highcost, 3))
  message("High movement, high costs: ", round(pred_highmove_highcost, 3))
  
  # Make file name
  fn = paste0("./figures/heatMapKorea", fileID, ".pdf")
  
  # Create file
  ggsave(fn, width=4.8, height=5.5)
}
